/*    */ package com.zimbra.cs.service.admin;
/*    */ 
/*    */ import com.zimbra.common.account.Key.DomainBy;
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ import com.zimbra.common.soap.AdminConstants;
/*    */ import com.zimbra.common.soap.Element;
/*    */ import com.zimbra.cs.account.AccountServiceException;
/*    */ import com.zimbra.cs.account.Domain;
/*    */ import com.zimbra.cs.account.Provisioning;
/*    */ import com.zimbra.cs.account.accesscontrol.AdminRight;
/*    */ import com.zimbra.cs.account.accesscontrol.Rights.Admin;
/*    */ import com.zimbra.cs.gal.GalSearchControl;
/*    */ import com.zimbra.cs.gal.GalSearchParams;
/*    */ import com.zimbra.cs.gal.GalSearchResultCallback;
/*    */ import com.zimbra.soap.ZimbraSoapContext;
/*    */ import com.zimbra.soap.type.GalSearchType;
/*    */ import java.util.List;
/*    */ import java.util.Map;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class AutoCompleteGal
/*    */   extends AdminGalDocumentHandler
/*    */ {
/*    */   public boolean domainAuthSufficient(Map context)
/*    */   {
/* 51 */     return true;
/*    */   }
/*    */   
/*    */   public Element handle(Element request, Map<String, Object> context) throws ServiceException
/*    */   {
/* 56 */     ZimbraSoapContext zsc = getZimbraSoapContext(context);
/*    */     
/* 58 */     String domainName = request.getAttribute("domain");
/* 59 */     Provisioning prov = Provisioning.getInstance();
/* 60 */     Domain domain = prov.get(Key.DomainBy.name, domainName);
/* 61 */     if (domain == null) {
/* 62 */       throw AccountServiceException.NO_SUCH_DOMAIN(domainName);
/*    */     }
/* 64 */     checkDomainRight(zsc, domain, Rights.Admin.R_accessGAL);
/*    */     
/* 66 */     String name = request.getAttribute("name");
/* 67 */     int limit = (int)request.getAttributeLong("limit", 0L);
/* 68 */     String typeStr = request.getAttribute("type", GalSearchType.account.name());
/* 69 */     GalSearchType type = GalSearchType.fromString(typeStr);
/*    */     
/* 71 */     String galAcctId = request.getAttribute("galAcctId", null);
/*    */     
/* 73 */     GalSearchParams params = new GalSearchParams(domain, zsc);
/* 74 */     params.setType(type);
/* 75 */     params.setRequest(request);
/* 76 */     params.setQuery(name);
/* 77 */     params.setLimit(limit);
/* 78 */     params.setResponseName(AdminConstants.AUTO_COMPLETE_GAL_RESPONSE);
/* 79 */     if (galAcctId != null) {
/* 80 */       params.setGalSyncAccount(Provisioning.getInstance().getAccountById(galAcctId));
/*    */     }
/* 82 */     params.setResultCallback(new SearchGal.AdminGalCallback(params));
/*    */     
/* 84 */     GalSearchControl gal = new GalSearchControl(params);
/* 85 */     gal.autocomplete();
/* 86 */     return params.getResultCallback().getResponse();
/*    */   }
/*    */   
/*    */ 
/*    */   public boolean needsAuth(Map<String, Object> context)
/*    */   {
/* 92 */     return true;
/*    */   }
/*    */   
/*    */   public void docRights(List<AdminRight> relatedRights, List<String> notes)
/*    */   {
/* 97 */     relatedRights.add(Rights.Admin.R_accessGAL);
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/service/admin/AutoCompleteGal.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */